<?php

class LoginController extends AController
{
	private $aloginform;
	private $cookiesTime = 0;
	public function actionIndex()
	{
		$this->aloginform = new AloginForm;
		if(isset($_POST['AloginForm']))
		{
			$this->aloginform->attributes = $_POST['AloginForm'];
			if($this->aloginform->validate())
			{	
				if($this->aloginform->rememberMe)
					$this->cookiesTime = Yii::app()->params['CookiesTime'];
				
				if(!Yii::app()->user->login($this->aloginform->_identity,$this->cookiesTime))
					Yii::app()->request->redirect(Yii::app()->user->returnUrl);
			}                        
		}
		else 
			Yii::app()->user->logout();
					
		$this->render('login',array(
			'aloginform' => $this->aloginform
		));
	}
	
	public function init()
	{
		$this->adminpublic=array(
			'leftsidecontent'=>"",
			'rightsidetop'=>""
		);
	}
}